import * as Cesium from 'cesium/Cesium'
var scratch$2 = new Cesium.Cartesian3
    , cart2 = new Cesium.Cartesian2
    , normalScratch$9 = new Cesium.Cartesian3
    , v1$3 = new Cesium.Cartesian3
    , rayScratch$4 = new Cesium.Ray
    , scratchCarto$4 = new Cesium.Cartographic;

function getHeightPosition(e, t) {
    var i = e._positions
        , r = i[0]
        , n = i[1]
        , a = e._draggingPlane
        , o = e._surfaceNormal
        , s = e._scene
        , l = s.camera
        , c = l.direction
        , u = s.frameState.mapProjection.ellipsoid
        , d = r
        , h = o;
    if (s.mode === Cesium.SceneMode.COLUMBUS_VIEW) {
        h =  Cesium.Cartesian3.UNIT_X;
        var p = u.cartesianToCartographic(r, scratchCarto$4);
        d = s.mapProjection.project(p, scratch$2),
            Cesium.Cartesian3.fromElements(d.z, d.x, d.y, d)
    }
    var m = Cesium.Cartesian3.cross(h, c, normalScratch$9);
    m = Cesium.Cartesian3.cross(h, m, m),
        m = Cesium.Cartesian3.normalize(m, m),
        a = Cesium.Plane.fromPointNormal(d, m, a);
    var f = l.getPickRay(t, rayScratch$4);
    if ( Cesium.defined(n =  Cesium.IntersectionTests.rayPlane(f, a, n))) {
        if (s.mode === Cesium.SceneMode.COLUMBUS_VIEW) {
            n = Cesium.Cartesian3.fromElements(n.y, n.z, n.x, n);
            var g = s.mapProjection.unproject(n, scratchCarto$4);
            n = u.cartographicToCartesian(g, n)
        }
        return  Cesium.SceneTransforms.wgs84ToWindowCoordinates(s, i[0], cart2).y < t.y && (o =  Cesium.Cartesian3
            .negate(o, normalScratch$9)),
            v1$3 = Cesium.Cartesian3.subtract(n, r, v1$3),
            v1$3 = Cesium.Cartesian3.projectVector(v1$3, o, v1$3),
            n = Cesium.Cartesian3.add(r, v1$3, n)
    }
}
export default getHeightPosition;